package com.testdemo.web.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.testdemo.web.dao.MyUserDao;
import com.testdemo.web.vo.MyUser;
import com.testdemo.web.vo.UserInfo;

/**
 * MyUserService实现.
 * @author Reeves
 *
 */
@Service
public class MyUserServiceImpl  implements MyUserService{

	/**
	 * MyUserDao对象.
	 */
	@Autowired
	private MyUserDao myUserDao;

	@Override
	public MyUser selectUserByNamePsw(String username, String userpsw) {
		return myUserDao.selectUserByNamePsw(username, userpsw);
	}

	@Override
	public MyUser selectUserByName(String username) {
		return myUserDao.selectUserByName(username);
	}

	@Override
	public int insertMyUser(MyUser u) {
		MyUser myUser = selectUserByName(u.getUsername());
		if (myUser == null) {
			myUserDao.insertMyUser(u);
			return 1;
		}
		return 0;
	}

	@Override
	public UserInfo selectUserInfoByName(String username) {
		
		return myUserDao.selectUserInfoByName(username);
	}

	@Override
	public int insertUserInfo(UserInfo userInfo) {
		
		return myUserDao.insertUserInfo(userInfo);
	}

	@Override
	public int updateUserInfo(UserInfo userInfo) {
		
		return myUserDao.updateUserInfo(userInfo);
	}

	@Override
	public int updatePassWord(MyUser user) {
		return myUserDao.updatePassWord(user);
		
	}

}
